package com.isoft.uaaservice.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.isoft.uaaservice.bean.SysPermission;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SysPermissionDao extends BaseMapper<SysPermission> {
    @Select("SELECT DISTINCT P.* " +
            "FROM TMIM_SYSTEM.SYS_PERMISSION P " +
            "INNER JOIN TMIM_SYSTEM.SYS_ROLE_PERMISSION RP ON P.ID = RP.PERMISSIONID " +
            "INNER JOIN TMIM_SYSTEM.SYS_ROLE R on RP.ROLEID = R.ID " +
            "INNER JOIN TMIM_SYSTEM.SYS_USER_ROLE UR ON R.ID = UR.ROLEID " +
            "INNER JOIN TMIM_SYSTEM.SYS_USER U ON UR.USERID = U.ID " +
            "WHERE PARENTID=0 AND U.ISLOCK = 0 AND U.ID= #{uid} AND P.STATUS = 0  " +
            "ORDER BY P.ORDERID;")
    public List<SysPermission> topPermissionByUserid(Integer uid);
}
